﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DWLib
{
    /// <summary>
    /// Digital Watch class containing hours, minutes and seconds
    /// </summary>
    public partial class DigitalWatchB : DigitalWatchA
    {
        public DigitalWatchB()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Increments a time object. (either hours, minutes or seconds)
        /// </summary>
        /// <returns>true when exceeded the maximum(enforces a reset); false otherwise.</returns>
        public override bool increment()
        {
            bool ret;

            switch (mode)
            {
                case 2:
                    ret = time.seconds.increment();
                    display();
                    break;

                case 1:
                case 0:
                default:
                    ret = base.increment();
                    break;
            }

            return ret;
        }

        /// <summary>
        /// Decrements Time object. (either hours, minutes or seconds)
        /// </summary>
        /// <returns>true when exceeded the minimum(enforces a reset); false otherwise.</returns>
        public override bool decrement()
        {
            bool ret;

            switch (mode)
            {
                case 2:
                    ret = time.seconds.decrement();
                    display();
                    break;

                case 1:
                case 0:
                default:
                    ret = base.decrement();
                    break;
            }

            return ret;
        }

        /// <summary>
        /// Default mode of the clock
        /// </summary>
        /// <returns>2</returns>
        protected override int maxValue()
        {
            return 2;
        }

        /// <summary>
        /// Show the time on the form.
        /// </summary>
        protected override void display()
        {
            //show hours and minutes from watchdisplayA depending on the mode
            base.display();
            // show seperator depending on the mode
            labelSeperator2.Text = (mode == -1 && flash) ? string.Empty : ":";
            // show seconds depending on the mode
            labelSeconds.Text = (mode == 2 && flash) ? string.Empty : time.seconds.ToString();
        }
    }
}
